<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    ul{
      list-style: none;
    }
    ul li {
      width: 500px;
      height: 30px;
      line-height: 30px;
      padding: 0 10px;
      border: 1px dashed #ccc;
      background: #eee;
    }
    .li-enter,.li-leave-to{
      opacity: 0;
      transform: translateY(200px);
    }
    .li-enter-active,.li-leave-active{
      transition: all 1.5s;
      /* 移除的元素，不能占位 */
      position: absolute;
    }
    /* 元素移除的过程，下一个元素会移动，动画可以实现 */
    .li-move{
      transition: all 1.5s;
    }
  </style>
</head>
<body>
  <div id="app">
    <!-- 如果是列表动画 需要是 transition-group 组件包裹 -->
    <!-- tag="ul" 解析成ul标签 -->
    <!-- name="li" 控制动画的六个类名以li开头，不是默认的v开头 -->
    <transition-group tag="ul" name="li">
      <li v-for="item in list" :key="item.id" @click="del(item.id)">{{item.name}}</li>
    </transition-group>
  </div>
  <script src="./vue.js"></script>
  <script>
    const vm = new Vue({
      el: '#app',
      data () {
        return {
          list: [
            {id:1,name:'周杰伦'},
            {id:2,name:'周生生'},
            {id:3,name:'周大福'},
            {id:4,name:'周某某'}
          ]
        }
      },
      methods: {
        // 删除
        del (id) {
          const index = this.list.findIndex(item=>item.id===id)
          this.list.splice(index,1)
        }
      }
    })
  </script>
</body>
</html>